package com.tjtt.demo.action;


import java.io.File;
import java.util.Calendar;
import java.io.IOException;
import java.io.PrintWriter;
import java.io.UnsupportedEncodingException;
import java.math.BigDecimal;
import java.sql.Timestamp;
import java.text.DecimalFormat;
import java.text.SimpleDateFormat;
import java.util.ArrayList;
import java.util.Date;
import java.util.Iterator;
import java.util.List;
import java.util.Map;

import javax.servlet.http.HttpServletResponse;

import jxl.Sheet;
import jxl.Workbook;

import org.apache.struts2.ServletActionContext;
import org.springframework.web.context.WebApplicationContext;
import org.springframework.web.context.support.WebApplicationContextUtils;

import com.sun.org.apache.bcel.internal.generic.NEW;
import com.tjtt.common.utils.ExcelExportUtil;
import com.tjtt.common.utils.TotalFlowXmlTool;
import com.tjtt.gwm.bean.EPInStore;
import com.tjtt.gwm.bean.EquipmentParts;
import com.tjtt.gwm.bean.Gongyingshang;
import com.tjtt.gwm.bean.Shebeifengcun;
import com.tjtt.gwm.bean.Weituodan;
import com.tjtt.gwm.service.EquipmentPartsService;
import com.tjtt.tdm.base.BaseAction;
import com.tjtt.tdm.base.PageResult;
import com.tjtt.tdm.base.PubMethod;
import com.tjtt.tdm.base.StringUtil;
import com.tjtt.tdm.flow.bean.FlowTask;
import com.tjtt.tdm.flow.bean.FlowTaskInfo;
import com.tjtt.tdm.flow.bean.Flowstate;
import com.tjtt.tdm.form.service.IAutoService;

import com.tjtt.tdm.codeReview.service.ICodeReviewService;
import com.tjtt.tdm.flow.bean.Flowtype;
public class  FlowDemoAction extends BaseAction{
	//跳转到流程发起页面
	public String flowFaQi(){
		String mainid=this.getRequest().getParameter("mainid");
		String flowid = this.getRequest().getParameter("flowid");
		String stateid=this.getRequest().getParameter("stateid");
		getRequest().setAttribute("flowid", flowid);
		getRequest().setAttribute("stateid", stateid);
		if(mainid==null||mainid.equals("")){
			mainid="22";
			getRequest().setAttribute("mainid", mainid);
			super.initFlowaddBase();
			
		}
		else{
			getRequest().setAttribute("mainid", mainid);
			super.initFlowupdateBase();
		}
		return "faqi";
	}
	//流程信息填写完毕后提交审核方法
	public void infoSubmit()throws IOException{
		String flag=this.getRequest().getParameter("flag");
		String mainid=this.getRequest().getParameter("id");
		String flowname=this.getRequest().getParameter("flowname");
		PrintWriter out=getResponse().getWriter();
	  try{
		  if(flag.equals("0")){
		super.saveFaqiBase("TDM_DEMO",mainid);}
		  else if(flag.equals("1")){
		 super.saveUpdateBase("TDM_DEMO", mainid);
		  }
		getRequest().setAttribute("message", "提交成功!");
		out.print("{\"result\":\"success\"}");
	    out.flush();
		out.close();
	  } catch (Exception e) {
		e.printStackTrace();
		getRequest().setAttribute("message", "提交失败");
		 out.print("{\"result\":\"error\"}");
	}
	}
	//跳转到审核页面
	public String flowShenHe(){
		String mainid = getRequest().getParameter("mainid");
		String flowid = this.getRequest().getParameter("flowid");
		String flowname = this.getRequest().getParameter("flowname");
		String stateid=this.getRequest().getParameter("stateid");
		getRequest().setAttribute("flowid", flowid);
		getRequest().setAttribute("stateid", stateid);
		super.initFlowupdateBase();
		return "shenhe";
	}
	//流程审核完毕后提交批准方法
	public void infoExamine()throws IOException{
		String mainid=this.getRequest().getParameter("mainid");
		PrintWriter out=getResponse().getWriter();
	  try{
		 super.saveUpdateBase("TDM_DEMO", mainid);
		getRequest().setAttribute("message", "提交成功!");
		out.print("{\"result\":\"success\"}");
	    out.flush();
		out.close();
	  } catch (Exception e) {
		e.printStackTrace();
		getRequest().setAttribute("message", "提交失败");
		 out.print("{\"result\":\"error\"}");
	}
	}
	//跳转到批准页面
	public String flowPiZhun(){
		String mainid = getRequest().getParameter("mainid");
		String flowid = this.getRequest().getParameter("flowid");
		String flowname = this.getRequest().getParameter("flowname");
		String stateid=this.getRequest().getParameter("stateid");
		getRequest().setAttribute("flowid", flowid);
		getRequest().setAttribute("stateid", stateid);
		super.initFlowupdateBase();
		return "pizhun";
	}
	//流程批准方法
	public void infoPass()throws IOException{
		String mainid=this.getRequest().getParameter("mainid");
		String step=this.getRequest().getParameter("steptype");
		PrintWriter out=getResponse().getWriter();
	  try{
		 super.saveUpdateBase("TDM_DEMO", mainid);
		getRequest().setAttribute("message", "提交成功!");
		out.print("{\"result\":\"success\"}");
	    out.flush();
		out.close();
	  } catch (Exception e) {
		e.printStackTrace();
		getRequest().setAttribute("message", "提交失败");
		 out.print("{\"result\":\"error\"}");
	}
	}

}
